//
//@File    :	7.15_arrobj.cpp
//@Time    :	2021/08/14 16:31:31
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	functions with array objects(C++)
//

#include <iostream>
#include <array>
#include <string>
using namespace std;

const int Seasons=4;
const array<string,Seasons> Snames={"Spring","Summer","Fall","Witer"};

void fill(array<double,Seasons> *pa);
void show(array<double,Seasons> da);

int main()
{
    array<double,Seasons> expenses;
    fill(&expenses);
    show(expenses);
    system("pause");
    return 0;
}
void fill(array<double,Seasons> *pa)//pa是指向一个arr<double,4>对象的指针
{
    for (int i = 0; i < Seasons; i++)
    {
        cout<<"Enter "<<Snames[i]<<" expenses: ";
        cin>>(*pa)[i];
    }
    
}
void show(array<double,Seasons> da)
{
    double total=0.0;
    cout<<"\nEXPENSES\n";
    for (int  i = 0; i < Seasons; i++)
    {
        cout<<Snames[i]<<": $"<<da[i]<<endl;
        total+=da[i];
    }
    cout<<"Total Expenses: $"<<total<<endl;
}